//
//  KFWMessageTabCell.m
//  KWNLaywerClient
//
//  Created by 孔六五 on 15/1/13.
//  Copyright (c) 2015年 张明磊. All rights reserved.
//

#import "KFWMessageTabCell.h"
#import "Model_questionDetailNew.h"
#import "Model_message.h"

@implementation KFWMessageTabCell

@synthesize label_timeLabel;
@synthesize label_nameImageLab;
@synthesize label_nameLab;
@synthesize label_textLab;
@synthesize imageview_head;
@synthesize imageview_imagehead;
@synthesize imageview_textQiPao;
@synthesize imageview_imageQiPao;
@synthesize imageview_one;
@synthesize imageview_two;
@synthesize imageview_imageWen;
@synthesize imageview_textWen;
@synthesize cellState;
@synthesize indexPath;
@synthesize delegate;

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        label_timeLabel = [UIUtils creatLabel];
        label_timeLabel.layer.cornerRadius = 4;
        label_timeLabel.layer.masksToBounds = YES;
        label_timeLabel.backgroundColor = RGB(230, 230, 230);
        label_timeLabel.font = FontOfSystem(10);
        label_timeLabel.textAlignment = NSTextAlignmentCenter;
        label_timeLabel.textColor = [UIColor whiteColor];
        label_timeLabel.frame = CGRectMake((MainScreenWidth - 100)/2, 10, 100, 20);
        [self addSubview:label_timeLabel];
    }
    return self;
}

- (void)creatSubViewsWithState:(KFWMessageCellState)state;
{
    switch (state) {
        case KFWMessageCellStateText:
        {
            imageview_head = [[UIImageView alloc] init];
            imageview_head.layer.masksToBounds = YES;
            imageview_head.userInteractionEnabled = YES;
            UITapGestureRecognizer *tapGestureViewTextHead =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(headClick:)];
            [imageview_head addGestureRecognizer:tapGestureViewTextHead];

            imageview_textWen = [[UIImageView alloc] init];

            label_nameLab = [UIUtils creatLabel];
            label_nameLab.font = FontOfSystem(11);
            label_nameLab.numberOfLines = 2;
            label_nameLab.textColor = RGB(115, 164, 213);
            imageview_textQiPao = [[UIImageView alloc] init];

            label_textLab = [UIUtils creatLabel];
            label_textLab.font = FontOfQuestionList;
            label_textLab.numberOfLines = 0;
            label_textLab.textColor = ColorOfQuestionList;

            [self addSubview:imageview_head];
            [self addSubview:imageview_textWen];
            [self addSubview:label_nameLab];
            [self addSubview:imageview_textQiPao];
            [self addSubview:label_textLab];
            self.cellState = state;
        }
            break;
        case KFWMessageCellStateImage:
        {
            imageview_imagehead = [[UIImageView alloc] init];
            imageview_imagehead.layer.masksToBounds = YES;
            imageview_imagehead.userInteractionEnabled = YES;
            UITapGestureRecognizer *tapGestureViewImageHead =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(headClick:)];
            [imageview_imagehead addGestureRecognizer:tapGestureViewImageHead];

            imageview_imageWen = [[UIImageView alloc] init];

            label_nameImageLab = [UIUtils creatLabel];
            label_nameImageLab.font = FontOfSystem(11);
            label_nameImageLab.numberOfLines = 2;
            label_nameImageLab.textColor = RGB(115, 164, 213);

            imageview_imageQiPao = [[UIImageView alloc] init];
            imageview_one = [[UIImageView alloc] init];
            imageview_one.tag = TagOfView + 1;
            imageview_one.userInteractionEnabled = YES;
            imageview_two = [[UIImageView alloc] init];
            imageview_two.tag = TagOfView + 2;
            imageview_two.userInteractionEnabled = YES;
            
            UITapGestureRecognizer *tapGestureViewOne =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(photoClick:)];
            [imageview_one addGestureRecognizer:tapGestureViewOne];

            UITapGestureRecognizer *tapGestureViewTwo =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(photoClick:)];
            [imageview_two addGestureRecognizer:tapGestureViewTwo];

            [self addSubview:imageview_imagehead];
            [self addSubview:imageview_imageWen];
            [self addSubview:label_nameImageLab];
            [self addSubview:imageview_imageQiPao];
            [self addSubview:imageview_one];
            [self addSubview:imageview_two];
            
            self.cellState = state;

        }
            break;
        case KFWMessageCellStateTextAddImage:
        {
            [self creatSubViewsWithState:KFWMessageCellStateText];
            [self creatSubViewsWithState:KFWMessageCellStateImage];
            
            //不能换位置  保持正确的state
            self.cellState = state;
        }
            break;
        default:
            break;
    }
}

- (void)changeViewFrameWith:(id)model
{
    if ([model isKindOfClass:[Model_questionDetailNew class]]) {
        Model_questionDetailNew *qD = model;
        switch (self.cellState) {
            case KFWMessageCellStateText:
            {
                imageview_head.frame = CGRectMake(5, 10+20+10, WidthOfHead, WidthOfHead);
                imageview_head.layer.cornerRadius = WidthOfHead/2;
                
                label_nameLab.frame = CGRectMake(5, 10+20+10 + WidthOfHead, WidthOfHead, 30);
                label_nameLab.numberOfLines = 2;
                label_nameLab.textAlignment = NSTextAlignmentCenter;
                
                imageview_textWen.hidden = NO;
                imageview_textWen.frame = CGRectMake(imageview_head.frame.origin.x + WidthOfHead - 18, imageview_head.frame.origin.y + WidthOfHead - 18, 18, 18);
                imageview_textWen.image = [UIImage imageFileName:@"wen.png"];
                
                CGSize textSize = [UIUtils cgrectFor:qD.string_question withFont:FontOfQuestionList labWidth:WidthMaxOfMessageImage - 25];
                label_textLab.frame = CGRectMake(5*2+WidthOfHead+15, imageview_head.frame.origin.y + 10, textSize.width, textSize.height);
                
                imageview_textQiPao.frame = CGRectMake(5*2+WidthOfHead, imageview_head.frame.origin.y, textSize.width + 25, textSize.height + 20);
                imageview_textQiPao.image = [[UIImage imageFileName:@"qipao_zuo.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(26,20,10,20) resizingMode:UIImageResizingModeStretch];
                
            }
                break;
            case KFWMessageCellStateImage:
            {
                imageview_imagehead.frame = CGRectMake(5, 10+20+10, WidthOfHead, WidthOfHead);
                imageview_imagehead.layer.cornerRadius = WidthOfHead/2;

                imageview_imageWen.hidden = NO;
                imageview_imageWen.frame = CGRectMake(imageview_imagehead.frame.origin.x + WidthOfHead - 18, imageview_imagehead.frame.origin.y + WidthOfHead - 18, 18, 18);
                imageview_imageWen.image = [UIImage imageFileName:@"wen.png"];

                label_nameImageLab.frame = CGRectMake(5, 10+20+10 + WidthOfHead, WidthOfHead, 30);
                label_nameImageLab.numberOfLines = 2;
                label_nameImageLab.textAlignment = NSTextAlignmentCenter;

                imageview_one.frame = CGRectMake(5*2+WidthOfHead+15, imageview_imagehead.frame.origin.y + 10, 50, 50);
                
                if (qD.arr_thumbnail.count > 1) {
                    imageview_two.hidden = NO;
                    imageview_two.frame = CGRectMake(imageview_one.frame.origin.x + 50+5, imageview_one.frame.origin.y, 50, 50);
                    imageview_imageQiPao.frame = CGRectMake(5*2+WidthOfHead, imageview_imagehead.frame.origin.y, 15 + 10 + 50 * 2 + 5, 50 + 10*2);

                }
                else
                {
                    imageview_two.hidden = YES;
                    imageview_imageQiPao.frame = CGRectMake(5*2+WidthOfHead, imageview_imagehead.frame.origin.y, 15 + 10 + 50, 50 + 10*2);
                }
                imageview_imageQiPao.image = [[UIImage imageFileName:@"qipao_zuo.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(26,20,10,20) resizingMode:UIImageResizingModeStretch];

            }
                break;
            case KFWMessageCellStateTextAddImage:
            {
                imageview_head.frame = CGRectMake(5, 10+20+10, WidthOfHead, WidthOfHead);
                imageview_head.layer.cornerRadius = WidthOfHead/2;
                
                imageview_textWen.hidden = NO;
                imageview_textWen.frame = CGRectMake(imageview_head.frame.origin.x + WidthOfHead - 18, imageview_head.frame.origin.y + WidthOfHead - 18, 18, 18);
                imageview_textWen.image = [UIImage imageFileName:@"wen.png"];

                label_nameLab.frame = CGRectMake(5, 10+20+10 + WidthOfHead, WidthOfHead, 30);
                label_nameLab.numberOfLines = 2;
                label_nameLab.textAlignment = NSTextAlignmentCenter;
                
                CGSize textSize = [UIUtils cgrectFor:qD.string_question withFont:FontOfQuestionList labWidth:WidthMaxOfMessageImage - 25];
                label_textLab.frame = CGRectMake(5*2+WidthOfHead+15, imageview_head.frame.origin.y + 10, textSize.width, textSize.height);
                
                imageview_textQiPao.frame = CGRectMake(5*2+WidthOfHead, imageview_head.frame.origin.y, textSize.width + 25, textSize.height + 20);
                imageview_textQiPao.image = [[UIImage imageFileName:@"qipao_zuo.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(26,20,10,20) resizingMode:UIImageResizingModeStretch];

                //根据text气泡或者text行名字label确定image行的frame
                if (imageview_textQiPao.frame.origin.y + imageview_textQiPao.frame.size.height > label_nameLab.frame.origin.y + label_nameLab.frame.size.height) {
                    imageview_imagehead.frame = CGRectMake(5, imageview_textQiPao.frame.origin.y + imageview_textQiPao.frame.size.height + 5, WidthOfHead, WidthOfHead);
                    imageview_imagehead.layer.cornerRadius = WidthOfHead/2;
                }
                else
                {
                    imageview_imagehead.frame = CGRectMake(5, label_nameLab.frame.origin.y + label_nameLab.frame.size.height + 5, WidthOfHead, WidthOfHead);
                    imageview_imagehead.layer.cornerRadius = WidthOfHead/2;
                }
                
                imageview_imageWen.hidden = NO;
                imageview_imageWen.frame = CGRectMake(imageview_imagehead.frame.origin.x + WidthOfHead - 18, imageview_imagehead.frame.origin.y + WidthOfHead - 18, 18, 18);
                imageview_imageWen.image = [UIImage imageFileName:@"wen.png"];

                
                label_nameImageLab.frame = CGRectMake(5, imageview_imagehead.frame.origin.y + imageview_imagehead.frame.size.height, WidthOfHead, 30);
                label_nameImageLab.numberOfLines = 2;
                label_nameImageLab.textAlignment = NSTextAlignmentCenter;
                
                imageview_one.frame = CGRectMake(5*2+WidthOfHead+15, imageview_imagehead.frame.origin.y + 10, 50, 50);
                
                if (qD.arr_thumbnail.count > 1) {
                    imageview_two.hidden = NO;
                    imageview_two.frame = CGRectMake(imageview_one.frame.origin.x + 50+5, imageview_one.frame.origin.y, 50, 50);
                    imageview_imageQiPao.frame = CGRectMake(5*2+WidthOfHead, imageview_imagehead.frame.origin.y, 15 + 10 + 50 * 2 + 5, 50 + 10*2);
                }
                else
                {
                    imageview_two.hidden = YES;
                    imageview_imageQiPao.frame = CGRectMake(5*2+WidthOfHead, imageview_imagehead.frame.origin.y, 15 + 10 + 50, 50 + 10*2);
                }
                
                imageview_imageQiPao.image = [[UIImage imageFileName:@"qipao_zuo.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(26,20,10,20) resizingMode:UIImageResizingModeStretch];

            }
                break;
            default:
                break;
        }
    }
    else
    {
        Model_message *message = model;
        switch (self.cellState) {
            case KFWMessageCellStateText:
            {
                CGSize textSize = [UIUtils cgrectFor:message.string_content withFont:FontOfQuestionList labWidth:WidthMaxOfMessageImage - 25];

                if ([message.string_type integerValue] == 0) {
                    //律师回答的
                    imageview_head.frame = CGRectMake(MainScreenWidth - 5 - WidthOfHead, 10+20+10, WidthOfHead, WidthOfHead);
                    imageview_textWen.hidden = YES;
                    imageview_textWen.frame = CGRectZero;
                    
                    label_nameLab.frame = CGRectMake(MainScreenWidth - 5 - WidthOfHead, 10+20+10 + WidthOfHead, WidthOfHead, 30);
                    label_textLab.frame = CGRectMake(MainScreenWidth - 5*2 - WidthOfHead - 15-textSize.width, imageview_head.frame.origin.y + 10, textSize.width, textSize.height);
                    imageview_textQiPao.frame = CGRectMake(label_textLab.frame.origin.x - 10, imageview_head.frame.origin.y, textSize.width + 25, textSize.height + 20);
                    imageview_textQiPao.image = [[UIImage imageFileName:@"qipao_you.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(26,10,8,20) resizingMode:UIImageResizingModeStretch];

                }
                else
                {
                    imageview_head.frame = CGRectMake(5, 10+20+10, WidthOfHead, WidthOfHead);
                    
                    imageview_textWen.hidden = NO;
                    imageview_textWen.frame = CGRectMake(imageview_head.frame.origin.x + WidthOfHead - 18, imageview_head.frame.origin.y + WidthOfHead - 18, 18, 18);
                    imageview_textWen.image = [UIImage imageFileName:@"wen.png"];

                    label_nameLab.frame = CGRectMake(5, 10+20+10 + WidthOfHead, WidthOfHead, 30);
                    label_textLab.frame = CGRectMake(5*2+WidthOfHead+15, imageview_head.frame.origin.y + 10, textSize.width, textSize.height);
                    imageview_textQiPao.frame = CGRectMake(5*2+WidthOfHead, imageview_head.frame.origin.y, textSize.width + 25, textSize.height + 20);
                    imageview_textQiPao.image = [[UIImage imageFileName:@"qipao_zuo.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(26,20,10,20) resizingMode:UIImageResizingModeStretch];

                }
                imageview_head.layer.cornerRadius = WidthOfHead/2;
                label_nameLab.numberOfLines = 2;
                label_nameLab.textAlignment = NSTextAlignmentCenter;
                
            }
                break;
            case KFWMessageCellStateImage:
            {
                if ([message.string_type integerValue] == 0) {
                    //律师回答的
                    imageview_imagehead.frame = CGRectMake(MainScreenWidth - 5 - WidthOfHead, 10+20+10, WidthOfHead, WidthOfHead);
                    imageview_imageWen.hidden = YES;
                    imageview_imageWen.frame = CGRectZero;
                    
                    label_nameImageLab.frame = CGRectMake(MainScreenWidth - 5 - WidthOfHead, 10+20+10 + WidthOfHead, WidthOfHead, 30);

                    imageview_one.frame = CGRectMake(MainScreenWidth - 5*2 - WidthOfHead - 15-50, imageview_imagehead.frame.origin.y + 10, 50, 50);
                    
                    if (message.arr_thumbnail.count > 1) {
                        
                        //第一个图片前移
                        imageview_one.frame = CGRectMake(MainScreenWidth - 5*2 - WidthOfHead - 15-50 -5 - 50, imageview_imagehead.frame.origin.y + 10, 50, 50);

                        imageview_two.hidden = NO;
                        imageview_two.frame = CGRectMake(imageview_one.frame.origin.x + 50 + 5, imageview_one.frame.origin.y, 50, 50);
                        imageview_imageQiPao.frame = CGRectMake(imageview_one.frame.origin.x - 10, imageview_imagehead.frame.origin.y, 15 + 10 + 50 * 2 + 5, 50 + 10*2);
                    }
                    else
                    {
                        imageview_two.hidden = YES;
                        imageview_imageQiPao.frame = CGRectMake(imageview_one.frame.origin.x - 10, imageview_imagehead.frame.origin.y, 15 + 10 + 50, 50 + 10*2);
                    }
                    imageview_imageQiPao.image = [[UIImage imageFileName:@"qipao_you.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(26,10,8,20) resizingMode:UIImageResizingModeStretch];

                }
                else
                {
                    imageview_imagehead.frame = CGRectMake(5, 10+20+10, WidthOfHead, WidthOfHead);
                    
                    imageview_imageWen.hidden = NO;
                    imageview_imageWen.frame = CGRectMake(imageview_imagehead.frame.origin.x + WidthOfHead - 18, imageview_imagehead.frame.origin.y + WidthOfHead - 18, 18, 18);
                    imageview_imageWen.image = [UIImage imageFileName:@"wen.png"];

                    label_nameImageLab.frame = CGRectMake(5, 10+20+10 + WidthOfHead, WidthOfHead, 30);
                    
                    imageview_one.frame = CGRectMake(5*2+WidthOfHead+15, imageview_imagehead.frame.origin.y + 10, 50, 50);
                    
                    if (message.arr_thumbnail.count > 1) {
                        imageview_two.hidden = NO;
                        imageview_two.frame = CGRectMake(imageview_one.frame.origin.x + 50 + 5, imageview_one.frame.origin.y, 50, 50);
                        imageview_imageQiPao.frame = CGRectMake(5*2+WidthOfHead, imageview_imagehead.frame.origin.y, 15 + 10 + 50 * 2 + 5, 50 + 10*2);
                    }
                    else
                    {
                        imageview_two.hidden = YES;
                        imageview_imageQiPao.frame = CGRectMake(5*2+WidthOfHead, imageview_imagehead.frame.origin.y, 15 + 10 + 50, 50 + 10*2);
                    }
                    imageview_imageQiPao.image = [[UIImage imageFileName:@"qipao_zuo.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(26,20,10,20) resizingMode:UIImageResizingModeStretch];

                }
                imageview_imagehead.layer.cornerRadius = WidthOfHead/2;
                label_nameImageLab.numberOfLines = 2;
                label_nameImageLab.textAlignment = NSTextAlignmentCenter;

            }
                break;
            case KFWMessageCellStateTextAddImage:
            {
                
                //第一行text的
                CGSize textSize = [UIUtils cgrectFor:message.string_content withFont:FontOfQuestionList labWidth:WidthMaxOfMessageImage - 25];
                
                if ([message.string_type integerValue] == 0) {
                    imageview_head.frame = CGRectMake(MainScreenWidth - 5 - WidthOfHead, 10+20+10, WidthOfHead, WidthOfHead);
                    imageview_textWen.hidden = YES;
                    imageview_textWen.frame = CGRectZero;
                    
                    label_nameLab.frame = CGRectMake(MainScreenWidth - 5 - WidthOfHead, 10+20+10 + WidthOfHead, WidthOfHead, 30);
                    label_textLab.frame = CGRectMake(MainScreenWidth - 5*2 - WidthOfHead - 15 - textSize.width, imageview_head.frame.origin.y + 10, textSize.width, textSize.height);
                    imageview_textQiPao.frame = CGRectMake(label_textLab.frame.origin.x - 10, imageview_head.frame.origin.y, textSize.width + 25, textSize.height + 20);
                    
                    imageview_textQiPao.image = [[UIImage imageFileName:@"qipao_you.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(26,10,8,20) resizingMode:UIImageResizingModeStretch];

                }
                else
                {
                    imageview_head.frame = CGRectMake(5, 10+20+10, WidthOfHead, WidthOfHead);
                    
                    imageview_textWen.hidden = NO;
                    imageview_textWen.frame = CGRectMake(imageview_head.frame.origin.x + WidthOfHead - 18, imageview_head.frame.origin.y + WidthOfHead - 18, 18, 18);
                    imageview_textWen.image = [UIImage imageFileName:@"wen.png"];

                    label_nameLab.frame = CGRectMake(5, 10+20+10 + WidthOfHead, WidthOfHead, 30);
                    label_textLab.frame = CGRectMake(5*2+WidthOfHead+15, imageview_head.frame.origin.y + 10, textSize.width, textSize.height);
                    imageview_textQiPao.frame = CGRectMake(5*2+WidthOfHead, imageview_head.frame.origin.y, textSize.width + 25, textSize.height + 20);
                    imageview_textQiPao.image = [[UIImage imageFileName:@"qipao_zuo.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(26,20,10,20) resizingMode:UIImageResizingModeStretch];

                }
                imageview_head.layer.cornerRadius = WidthOfHead/2;
                label_nameLab.numberOfLines = 2;
                label_nameLab.textAlignment = NSTextAlignmentCenter;
                
                //第二行image
                
                if (imageview_textQiPao.frame.origin.y + imageview_textQiPao.frame.size.height > label_nameLab.frame.origin.y + label_nameLab.frame.size.height) {
                    if ([message.string_type integerValue] == 0) {
                        imageview_imagehead.frame = CGRectMake(MainScreenWidth - 5 - WidthOfHead, imageview_textQiPao.frame.origin.y + imageview_textQiPao.frame.size.height + 5, WidthOfHead, WidthOfHead);
                    }
                    else
                    {
                        imageview_imagehead.frame = CGRectMake(5, imageview_textQiPao.frame.origin.y + imageview_textQiPao.frame.size.height + 5, WidthOfHead, WidthOfHead);
                    }
                }
                else
                {
                    if ([message.string_type integerValue] == 0) {
                        imageview_imagehead.frame = CGRectMake(MainScreenWidth - 5 - WidthOfHead, label_nameLab.frame.origin.y + label_nameLab.frame.size.height + 5, WidthOfHead, WidthOfHead);

                    }
                    else
                    {
                        imageview_imagehead.frame = CGRectMake(5, label_nameLab.frame.origin.y + label_nameLab.frame.size.height + 5, WidthOfHead, WidthOfHead);
                    }
                }
                
                if ([message.string_type integerValue] == 0) {
                    //律师回答的
                    imageview_imageWen.hidden = NO;
                    imageview_imageWen.frame = CGRectZero;

                    label_nameImageLab.frame = CGRectMake(MainScreenWidth - 5 - WidthOfHead, imageview_imagehead.frame.origin.y + WidthOfHead, WidthOfHead, 30);
                    
                    imageview_one.frame = CGRectMake(MainScreenWidth - 5*2 - WidthOfHead - 15-50, imageview_imagehead.frame.origin.y + 10, 50, 50);
                    
                    if (message.arr_thumbnail.count > 1) {
                        
                        //第一张图片前移
                        imageview_one.frame = CGRectMake(MainScreenWidth - 5*2 - WidthOfHead - 15 - 50*2 - 5, imageview_imagehead.frame.origin.y + 10, 50, 50);

                        
                        imageview_two.hidden = NO;
                        imageview_two.frame = CGRectMake(imageview_one.frame.origin.x + 50 + 5, imageview_one.frame.origin.y, 50, 50);
                        imageview_imageQiPao.frame = CGRectMake(imageview_one.frame.origin.x - 10, imageview_imagehead.frame.origin.y, 15 + 10 + 50 * 2 + 5, 50 + 10*2);
                    }
                    else
                    {
                        imageview_two.hidden = YES;
                        imageview_imageQiPao.frame = CGRectMake(imageview_one.frame.origin.x - 10, imageview_imagehead.frame.origin.y, 15 + 10 + 50, 50 + 10*2);
                    }
                    imageview_imageQiPao.image = [[UIImage imageFileName:@"qipao_you.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(26,10,8,20) resizingMode:UIImageResizingModeStretch];

                }
                else
                {
                    
                    imageview_imageWen.hidden = NO;
                    imageview_imageWen.frame = CGRectMake(imageview_imagehead.frame.origin.x + WidthOfHead - 18, imageview_imagehead.frame.origin.y + WidthOfHead - 18, 18, 18);
                    imageview_imageWen.image = [UIImage imageFileName:@"wen.png"];

                    label_nameImageLab.frame = CGRectMake(5, imageview_imagehead.frame.origin.y + WidthOfHead, WidthOfHead, 30);
                    
                    imageview_one.frame = CGRectMake(5*2+WidthOfHead+15, imageview_imagehead.frame.origin.y + 10, 50, 50);
                    
                    if (message.arr_thumbnail.count > 1) {
                        imageview_two.hidden = NO;
                        imageview_two.frame = CGRectMake(imageview_one.frame.origin.x + 50+5, imageview_one.frame.origin.y, 50, 50);
                        imageview_imageQiPao.frame = CGRectMake(5*2+WidthOfHead, imageview_imagehead.frame.origin.y, 15 + 10 + 50 * 2 + 5, 50 + 10*2);
                    }
                    else
                    {
                        imageview_two.hidden = YES;
                        imageview_imageQiPao.frame = CGRectMake(5*2+WidthOfHead, imageview_imagehead.frame.origin.y, 15 + 10 + 50, 50 + 10*2);
                    }
                    imageview_imageQiPao.image = [[UIImage imageFileName:@"qipao_zuo.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(26,20,10,20) resizingMode:UIImageResizingModeStretch];

                }
                imageview_imagehead.layer.cornerRadius = WidthOfHead/2;
                label_nameImageLab.numberOfLines = 2;
                label_nameImageLab.textAlignment = NSTextAlignmentCenter;

            }
                break;
            default:
                break;
        }

    }
}


- (void)photoClick:(UIGestureRecognizer *)tap
{
    UIImageView *imageview = (UIImageView *)tap.view;
    if (self.delegate && [self.delegate respondsToSelector:@selector(clickPhoto:cellIndexPath:)]) {
        [self.delegate clickPhoto:imageview.tag cellIndexPath:self.indexPath];
    }
}

- (void)headClick:(UIGestureRecognizer *)tap
{
    
    if (self.delegate &&[self.delegate respondsToSelector:@selector(clickHeadCellIndexPath:)]) {
        [self.delegate clickHeadCellIndexPath:self.indexPath];
    }
}

@end
